//////////////////////////////////////////////////////////////////////////////////
//	 Copyright 2011 by Yosef Grabivker, ryuho@homenetworksoft.com
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.
//////////////////////////////////////////////////////////////////////////////////

#ifndef __WIRELESS_TAB_YG_H__
#define __WIRELESS_TAB_YG_H__

#include "def.h"
#include "logctrl.h"
#include "searchimpl.h"

typedef struct tagWIRELESSCLIENT
{
	wxString	strMAC;
	wxString	strRateset;
	wxString	strIdleTime;
	wxString	strTimeInNetwork;
	wxString	strState;
	size_t		stTXPkts;
	size_t		stTXFailPkts;
	size_t		stRXUcastPkts;
	size_t		stRXMBCastPkts;
	size_t		stTXRate;
	size_t		stRXRate;
	int			nSignalStrength;
}WIRELESSCLIENT;

class CWirelessTab: public wxPanel, public IGUIBind, public CSearchImpl<CWirelessTab>, public ILoggable, public ITabedPageUI
{
public:
								CWirelessTab(class wxWindow* pParent);
	virtual						~CWirelessTab(void);

	//IGUIBind
	virtual void				OnResponse(const COMMANDRESPONSE& resp);
	virtual void				Reset();


	//ISearchProvider
	virtual void 				GetSearchFields(SEARCHFIELD*& sf, size_t& sz);
	virtual cSearchOwnerID		GetID()				{ return cSearchOwnerIDWireless; }
	virtual void				OnFilterChanged();

	void						OnContextMenu(long id, long col) {}

	bool						OnDropText(wxCoord x, wxCoord y, const wxString& data) { return false; }
	void						OnDragDropFinished( wxWindowID id, wxDragResult result) {}

	long						GetItemCount(wxWindowID id=wxID_ANY)
	{
		return m_entries.size();
	}


	wxString					GetItemText(long item, long column, wxWindowID id=wxID_ANY);

	int							GetItemColumnImage(long item, long column, wxWindowID id=wxID_ANY);
	


	virtual int					GetItemImage(long item, wxWindowID id=wxID_ANY)
	{
		return -1;
	}


	static bool					m_bSortAsc;

	virtual wxString			GetLog();
	virtual cTabPageID			GetTabID() { return cTabIDWireless; }

protected:
	void						OnColumn(wxListEvent& ev);
	DECLARE_EVENT_TABLE()

protected:
	void						DoSort();
	void						DoFilter();
	void						ProcessData();
	wxString					FieldToString( int iFieldID, const WIRELESSCLIENT& entry);

	void						ShowAnalyze(const RTSTRING& str);
	void						ShowApData(const RTSTRING& str);

//	wxString					BuildStatTable(class CMarkupSTL& doc);
	wxString					BuildTableLine(const wxString& strProblem,	const wxString& strSolution, int& nOrder);
//	wxString					BuildStatTableLine(class CMarkupSTL& doc, const char* szXMLATTR,   const wxString& strValName, int& nOrder, bool& bShow );


private:
	
	class wxListCtrl*			m_pList;
	class CWirelessStatPanel*	m_pStatPanel;
	class wxHtmlWindow*			m_pAnylizeWindow;

	typedef std::vector<WIRELESSCLIENT>	WIRELESSCLIENTS;

	WIRELESSCLIENTS				m_entries;
	WIRELESSCLIENTS				m_entriesBeforeFilter;

	unsigned int				m_nSortCol;

	class CSearchPanel*			m_pSearch;
	long						m_lSearchResLine;
	class wxImageList*			m_pImageList;

};

#endif //__WIRELESS_TAB_YG_H__